
import { request } from "../../utils/request";
import config from "../../utils/config";

const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        picUrl: config.picUrl,
        custom: wx.getMenuButtonBoundingClientRect(),
        userInfo:{},
        page:1,
        last_page:1,
        endHide:true,
        list:[]
    },
    onLoad(options) {
        wx.hideShareMenu()
        var timer = setInterval(() => {
            var userInfo = wx.getStorageSync('userInfo')
            if (userInfo) {
                this.setData({ userInfo })
                this.getList()
                clearInterval(timer)
            }
        }, 500)
    },
    onShow() {

    },
    getList(){
        request({url:"/miniprogram/user/getMyCollectList",data:{user_id:this.data.userInfo.id,page:this.data.page}}).then(res=>{
            if(this.data.page == 1){
                this.setData({list:[]})
            }
            this.setData({list:this.data.list.concat(res.data),last_page:res.last_page})
        })
    },
    onReachBottom() {
        console.log(1)
        if(this.data.page >= this.data.last_page){
            this.setData({endHide:false})
            return false;
        }
        this.setData({page:this.data.page+1})
        this.getList()
    }
})